package com.zzxy.spring.po;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.core.ResolvableType;

/*1.instantiate bean对象实例化
        2.populate properties 封装属性
        3.如果Bean实现BeanNameAware 执行 setBeanName
        4.如果Bean实现BeanFactoryAware 执行setBeanFactory ，获取Spring容器
        5.如果存在类实现 BeanPostProcessor（后处理Bean） ，执行postProcessBeforeInitialization
        6.如果Bean实现InitializingBean 执行 afterPropertiesSet
        7.调用<bean init-method="init"> 指定初始化方法 init
        8.如果存在类实现 BeanPostProcessor（处理Bean） ，执行postProcessAfterInitialization
        执行业务处理
        9.如果Bean实现 DisposableBean 执行 destroy
        10.调用<bean destroy-method="customerDestroy"> 指定销毁方法 customerDestroy*/
public abstract class user implements BeanNameAware , BeanFactory {
    private String username;

    public user(String username) {
        this.username = username;
    }
    private void setUsername(String username){
        this.username=username;
        System.out.println("2.set properties ...");
    }

    public user() {
        System.out.println("1.init instance ...");
    }

    @Override
    public void setBeanName(String s) {
        System.out.println("3.set bean name ...");
    }
    public  void  setBeanFactory(BeanFactory beanFactory)throws BeansException{
        System.out.println("4.bean bean factory");
    }

    public void afterPropertiesSet() throws Exception {
        System.out.println("6.after properties ...");
    }

    public void myInit(){
        System.out.println("7.my.init ...");
    }


    public void destroy() throws Exception {
        System.out.println("9.destroy...");
    }

    public void myDestroy(){
        System.out.println("10.my destroy...");
    }
}

